#pragma once

#ifndef _DROPLET_BASE
#define _DROPLET_BASE

#ifdef _WIN32
#include "inttypes.h"
#elif
#include <inttypes.h>	// inttypes.h is included in UNIX systems
#endif

#include "btBulletDynamicsCommon.h"

#include "DropletSimGlobals.h"
#include "DropletDataStructs.h"

#include <cstdlib>

class Droplet_base
{
private :

	DropletActuatorData *actDat;
	DropletSensorData *senseDat;
	DropletCommData *commDat;
	DropletCompData *compDat;


	friend void AccessActuatorData(Droplet_base *pDroplet, DropletActuatorData *actDat);
	friend void AccessSensorData(Droplet_base *pDroplet, DropletSensorData *senseDat);
	friend void AccessCommData(Droplet_base *pDroplet, DropletCommData *commDat);
	friend void AccessCompData(Droplet_base *pDroplet, DropletCompData *compDat);

protected :

// Droplet Subsystems Setup Functions
	void ResetAllSystems(void);
	void ResetLED(void);
	void ResetCommSystem(void);
	void ResetRGBSensor(void);
	void ResetMotors(void);
	void GetDropletID(uint16_t *id);

// Droplet Motion Subsystem Functions
	void Rotate(uint8_t dur, turn_direction dir);
	void Move(uint8_t dur, move_direction dir);
	uint8_t CancelRotate(void);
	uint8_t CancelMove(void);
	uint8_t IsRotating(void);
	uint8_t IsMoving(void);

// TODO : Droplet Sensor Subsystem Functions
	void SetLED(uint8_t r, uint8_t g, uint8_t b);

// TODO : Droplet Communication Subsystem Functions

public :

// Constructor and Destructor
	Droplet_base(
		float x, 
		float y, 
		float a, 
		btCollisionShape *colShape,
		btTransform *startTransform,
		btDiscreteDynamicsWorld *dynamicsWorld);

	~Droplet_base();

// Droplet Simulator Functions to be overridden
	virtual void DropletInit(void) = 0;
	virtual void DropletMainLoop(void) = 0;
	virtual void DropletComplete(void) = 0;
};

#endif